package server;

/* LogActionsServer
 * ---------------------------------------------------
 * Written by
 * Rebecca Van Bussel 6271316
 * October 6, 2013
 */


import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintWriter;

public class LogActionsServer {

	private PrintWriter pw;

	private String ext="";

	public LogActionsServer(String serverName) {
		ext=serverName+"_logs";
		
		//make directory if it doesn't exist
		File logFolder = new File(ext);
		//make directory
		if (!logFolder.exists())
			logFolder.mkdir();

		String filename=ext+"/logs.txt";

		try {
			pw = new PrintWriter(new FileOutputStream(filename, true), true);
		} catch (FileNotFoundException e) {
			System.out.println("Error opening log file.");
			e.printStackTrace();
		}

	}

	public void addAction(String action) {
		pw.println(action);

	}

	public void closeFile() {
		pw.close();

	}

}
